import 'package:flutter_eve_plugin/store/base_action.dart';
import 'package:flutter_eve_plugin/store/ye_xiu/login/main.dart';
import 'package:redux/redux.dart';
import 'constant.dart';

LoginState loginReducer(LoginState state, action) {
  if (!(action is BaseAction)) {
    return state;
  }
  BaseAction baseAction = action;
  switch (baseAction.type) {
    case YX_AREA_CODE:
      return state.copyWith(areaCode: baseAction.data);
    case YX_PHONE:
      return state.copyWith(phone: baseAction.data);
    case YX_CODE:
      return state.copyWith(code: baseAction.data);
    case YX_NICK_NAME:
      return state.copyWith(nickName: baseAction.data);
    case YX_BIRTHDAY:
      return state.copyWith(birthday: baseAction.data);
    case YX_SEX:
      return state.copyWith(sex: baseAction.data);
    case YX_WIFI_NAME:
      return state.copyWith(wifiName: baseAction.data);
    case YX_WIFI_PASS:
      return state.copyWith(wifiPass: baseAction.data);
    case YX_BIND_RES:
      return state.copyWith(bindResultModel: baseAction.data);
  }
  return state;
}

// ignore: non_constant_identifier_names
final LoginReducer = combineReducers<LoginState>([loginReducer]);
